<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/6/24
 * Time: 15:59
 * Email：290776006@qq.com
 */
namespace app\index\model;
use think\Model;

class vo_video_class extends Model
{
    protected $table = 'vo_video_class';

    public function get_count()
    {
        return $this->count();
    }

    public function get_video_class()
    {
        return $this->field('classId, className, hotNum, show, IsDelete')->select();
    }

    /*
     * $show string
     * "0,1" 表示PC显示，"0,2" 表示小程序显示，"0,3" 表示H5显示，
     */
    public function get_video_class_by_show($show = "0", $is_delete = 0)
    {
        return $this->field('classId, className, hotNum, show, IsDelete')
            ->whereIn('show', $show)
            ->where('IsDelete', $is_delete)
            ->order('hotNum', 'desc')
            ->select();
    }

    public function del_video_class($classId)
    {
        return $this->where('classId', '=', $classId)->delete();
    }

    public function update_video_class($cid, $show_type)
    {
        $data = [
            'show' => $show_type
        ];

        return $this->where('classId', '=', $cid)->data($data)->update();
    }

    public function update_show_video_class($cid, $is_delete)
    {
        $data = [
            'IsDelete' => $is_delete
        ];

        return $this->where('classId', '=', $cid)->data($data)->update();
    }

    public function video_class_info_update($classId, $className, $hotNum)
    {
        $data = [
            'className' => $className,
            'hotNum' => $hotNum
        ];

        return $this->where('classId', '=', $classId)->data($data)->update();
    }
}